package com.rent.car.config;

/**
 * @author ygl
 * @create 2022-03-12 12:36
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 如果你旧项目需要转SpringBoot，需要定义此配置类，覆盖默认的视图解析器。
 * 在此类中不添加@EnableWebMvc注解，则会保留SpringBoot原本的Mvc配置；否则，会覆盖所有的SpringBoot对Spring MVC的默认配置。
 * <p>
 * 在application.properties中配置：spring.mvc.view.prefix/spring.mvc.view.suffix是没有作用的！！！
 */
@Slf4j
@Configuration
public class PersonalMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/system/main/login");

        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);

        WebMvcConfigurer.super.addViewControllers(registry);
    }

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/view/", ".jsp");
    }
}
